import VueRouter  from "vue-router";
import About from "../components/About.vue";
import Home from "../components/Home.vue";
import Message from "../components/Message.vue";
import News from "../components/News.vue";
import Detail from "../components/Detail.vue";

export default new VueRouter({
    routes:[
        {
            path:'/about',
            component:About,
        },
        {
            path:'/home',
            component:Home,
            children:[
                {
                    path:'message',
                    component:Message,
                    children:[
                        {
                            name:'detail',
                            path:'detail',
                            //props:true,
                            component:Detail
                        },
                        {
                            name:'_detail',
                            path:'_detail/:id/:title',
                            component:Detail,
                            //props:true,
                            //props的函数写法：
                            props($route){
                                console.log('路由传参，props的函数写被执行');
                                return{
                                    id:$route.params.id,
                                    title:$route.params.title,
                                    a:'111',
                                    b:'222'
                                }
                            }
                        },
                    ]
                },
                {
                    path:'news',
                    component:News

                }
            ]
        },
    ]
})